import Vue from 'vue'
import Router from 'vue-router'
import home from '@/components/home'
import HomeDetail from '@/components/home-detail'
import HomeList from '@/components/home-list'
import HomeListItem from '@/components/home-list-item'

import discover from '@/components/discover'
import DiscoverDetail from '@/components/discover-detail'

import contact from '@/components/contact'


Vue.use(Router)

export default new Router({
	mode: 'history',//添加此参数，页面预览时后面就不会带有#字符了
  routes: [
    {
      path: '/home',
      name: 'home',
      component: home,
      children:[//嵌套路由，每个子路由要在其父路由home.vue组建中添加<router-view></router-view>
	      {
	      	path: 'home-detail',
		      name: 'HomeDetail',
		      component: HomeDetail
	      },{
	      		path: '/home',
					//重定向：当我输入/home时，页面自动跳转到/home/home-detail
  				//redirect:'/home/home-detail'
    				redirect: { name: 'HomeDetail' }//通过name跳转
	      }, {
	      	path: 'home-list',
		      name: 'HomeList',
		      component: HomeList,
		      children:[
			      {//嵌套路由，每个子路由要在其父路由home-list.vue组建中添加<router-view></router-view>
			      	path: 'home-list-item',
				      name: 'HomeListItem',
				      component: HomeListItem
			      }
		      ]
	      }
      ]
    }, {
    	path: '/',
//重定向：当我输入http://localhost:8080时，页面自动跳转到http://localhost:8080/home
    	redirect:'/home'
    }, {
    	path: '/discover',
      name: 'discover',
      component: discover ,
      children:[
		      {
		    	path: 'discover-detail',
		      name: 'DiscoverDetail',
		      component: DiscoverDetail     
		    }
      ]
    }, {
    	path: '/contact/:id',//:id为站位作用，可自定义
      name: 'contact',
      component: contact
    }
  ]
})
